using UnityEngine;

public class GUIManager : MonoBehaviour {
	
	public Tutorial tutorial;
	private ISideMenu selection;
	private ISideMenu standardMenu = new NoSelectionMenu();
	
	void Start()
	{
		selection = standardMenu;
	}
	
	void OnGUI () {
		Rect SidePane    = GUILayout.Window(0, new Rect(10,10,Screen.width/8, Screen.height - 20), selection.SideMenu, "");;
		Rect MessagePane = GUILayout.Window(1, new Rect(Screen.width/8 + 20, 5*Screen.height/6 -10, Screen.width/6, Screen.height/6),
										tutorial.Message, "Tutorial");
		if (Input.GetMouseButtonUp(0) 
			&& !MessagePane.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y))
			&& !SidePane.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)))
		{
			Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
			RaycastHit hit;
			if(Physics.Raycast(ray, out hit))
			{
				selection = hit.transform.GetComponent(typeof(ISideMenu)) as ISideMenu;
			}
			else
			{
				selection = standardMenu;
			}
		}
	}
}

public interface ISideMenu
{
	void SideMenu (int windowID);
}

public interface IMessage
{
	void Message (int windowID);
}